<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>个人中心</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <style>
        html,
        body {
            width: 100%;
            min-height: 100%;
            background: #F2EFED;
        }

        .aui-active .aui-bar-tab-label {
            color: #f5a51c
        }

        .login {
            height: 10rem;
            background-image: -webkit-linear-gradient(0deg, #f5c674, #ed824c);
            /*background-image: url(../../image/personal_bkg.jpg);background-repeat: no-repeat; background-size: cover;*/
            position: relative;
        }

        .login .personal_logo {
            margin: 0 auto 9px;
            /*position: absolute; top: 60px; left: 20px;*/
        }

        .login .userinfo {
            position: absolute;
            text-align: center;
            left: 0;
            right: 0;
        }

        .login .userinfo .title {
            font-size: 0.8rem;
            color: #fff;
        }
        /* 设置条目 */

        .item {
            height: 3rem;
            line-height: 3rem;
            padding-left: 0.7rem;
            background-color: #fff;
        }

        .item_ico {
            float: left;
            width: 2.3rem;
            padding: 0.7rem 0.7rem 0.7rem 0;
        }

        .item_arrow {
            float: right;
            width: 1.5rem;
            padding: 1rem 0.7rem 1rem 0;
        }

        .item span {
            font-size: 0.7rem;
        }
        .app_ul {
          min-height: calc(100vh - 2rem);
        }
    </style>
</head>

<body>
    <div id="app" style="padding-top:10px;">
      <div class="app_ul aui-refresh-content">

        <ul class="aui-list aui-media-list">
            <li class="aui-list-item aui-list-item-middle" v-for="item in list">
                <div class="aui-media-list-item-inner">
                    <div class="aui-list-item-media" style="width:3rem">
                        <img :src="item.head_img" class="aui-list-img-sm">
                    </div>
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-text">
                            <div class="aui-list-item-title aui-font-size-14">{{item.username}}</div>
                            <div class="aui-list-item-right" @click="openWin_xd(item.user_id)" style="width:3rem;height:1.3rem;line-height:1.3rem;text-align:center;border:1px solid #ff8000;color:#ff8000;position: relative;top: 0.5rem;">去逛逛</div>
                        </div>
                        <div class="aui-list-item-text" style="font-size:0.6rem;">
                            共计{{item.goods_count}}件商品
                        </div>
                    </div>
                </div>
            </li>
        </ul>
      </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript">
    function goback() {
        api.closeWin();
    }


    apiready = function(url) {
            var app = new Vue({
                el: '#app',
                data: { //所有需要用到的数据
                    token: '',
                    page: 1,
                    totalpage: 1,
                    list: [],
                },
                created: function() { //创建好vue对象后执行，可处理数据
                    var $_this = this;
                    $_this.token = $api.getStorage('token') || ''

                    $_this.gx()

                    var scroll = new auiScroll({
                        listen: true, //是否监听滚动高度，开启后将实时返回滚动高度
                        distance: 40 //判断到达底部的距离，isToBottom为true
                    }, function(ret) {
                        if (ret.isToBottom) {
                            $_this.page++
                                if ($_this.page > $_this.totalpage) {
                                    $_this.page = $_this.totalpage
                                    return
                                }
                            api.ajax({
                                url: window.Url.Freeucenter_myBranch,
                                method: 'post',
                                data: {
                                    values: {
                                        token: $_this.token,
                                        page: $_this.page
                                    }
                                },
                                timeout: 300,
                            }, function(ret, err) {
                                if (ret) {
                                    //  api.alert({ msg: JSON.stringify(ret) });
                                    // console.log(JSON.stringify(ret));
                                    if (ret.re == 1) {
                                        $_this.list = $_this.list.concat(ret.data.list)
                                    }

                                } else {
                                    api.alert({
                                        msg: JSON.stringify(err)
                                    });
                                }
                            })
                        }

                    })
                },
                mounted: function() { //页面渲染完成后执行，不包括需要请求的数据
                    // 如在这里开始渲染地图!!! initMap()
                    var $_this = this;
                    $_this.setRefresh()
                },
                methods: {
                  openWin_xd:function(id) {
                    api.openWin({
                        name: 'myshop',
                        url: './headerTwo.html',
                        pageParam: {
                            msg: '',
                            id:id,
                            url: './myshop.html'
                        }
                    });
                  },
                    gx: function() {
                        var $_this = this;
                        $_this.page = 1;
                        api.ajax({
                            url: window.Url.Freeucenter_myBranch,
                            method: 'post',
                            data: {
                                values: {
                                    token: $_this.token,
                                    page: $_this.page
                                }
                            }
                        }, function(ret, err) {
                            if (ret) {
                                if (ret.re != 1) {
                                    api.toast({
                                        msg: ret.info,
                                        duration: 2000,
                                        location: 'bottom'
                                    });
                                } else {
                                    $_this.list = ret.data.list
                                    $_this.totalpage = ret.sum_page
                                }
                                console.log(JSON.stringify(ret));
                            } else {
                                api.alert({
                                    msg: JSON.stringify(err)
                                });
                            }
                        })
                    },
                    setRefresh: function() {
                        var $_this = this;
                        var pullRefresh = new auiPullToRefresh({
                            container: document.querySelector('.aui-refresh-content'),
                            triggerDistance: 100
                        }, function(ret) {
                            if (ret.status == "success") {
                                $_this.page = 1;
                                $_this.gx()
                                setTimeout(function() {
                                    pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                                }, 500)
                            }
                        })
                    }
                }
            });
        }
</script>

</html>
